package com.lzx.iteam.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.lzx.iteam.R;

public class DialogListAdapter extends BaseAdapter{
    
    private String[] mData;
    private LayoutInflater mInflater;
    
    public DialogListAdapter(Context context) {
        mInflater = LayoutInflater.from(context);
    }
    
    public void setData(String[] data){
        mData = data;
    }

    @Override
    public int getCount() {

        if(mData.length>0){
            return mData.length+1;
        }
        return mData.length;
    }

    @Override
    public String getItem(int position) {

        if(position < mData.length){
            return mData[position];
        }
        return null;
    }

    @Override
    public long getItemId(int position) {

        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        TextView tvItem;
        if(convertView == null){
            view = mInflater.inflate(R.layout.item_dialog_list, null);
            tvItem = (TextView)view.findViewById(R.id.tv_item_btn);
            view.setTag(tvItem);
        }else{
            tvItem = (TextView) view.getTag();
        }
        if(position == mData.length){
            tvItem.setTextColor(0xff333333);
            tvItem.setText("取消");
        }else{
            tvItem.setTextColor(0xff0061a9);
            tvItem.setText(getItem(position));
        }
        return view;
    }
    

}
